package com.gzcsqic.excelapp.utils;

import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

public class OsUtil {

    public static String getPath() {
        String jar_parent = "";
        try {
            jar_parent = new File(ResourceUtils.getURL("classpath:").getPath()).getParentFile().getParentFile().getParent();
            if(jar_parent.startsWith("file:")){
                jar_parent = jar_parent.substring(6);
            }else if(jar_parent.startsWith(File.separator)){
                jar_parent = jar_parent.substring(1);
            }
            return jar_parent + File.separator;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return jar_parent;

    }
}
